package com.example.ineedahelp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

import com.netmera.mobile.NetmeraCallback;
import com.netmera.mobile.NetmeraException;
import com.netmera.mobile.NetmeraUser;

public class LoginActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}

	public void login(View view){
		final EditText email = (EditText)findViewById(R.id.email);
		final EditText password = (EditText)findViewById(R.id.password);
		
		NetmeraUser.loginInBackground(email.getText().toString(), password.getText().toString(), new NetmeraCallback< NetmeraUser>() {
		    @Override
		    public void callback(NetmeraUser result, NetmeraException exception) {
		        if (result != null && exception == null) {
	                Intent intent = new Intent(getApplicationContext(),HelpActivity.class);
	                startActivity(intent);
		        } else {
		          // Error occurred
		        }
		    }
		});
	}
	
}
